<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'addUser.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body{
font-size:12px;
}
div{
	width:500px;
	height:500px;
	
}
table{
	margin-left:50px;
	font-size:13px;
}
select{
width:156px;
}
.bt{
width:80px;

margin-top:30px;
}
#btn1{
margin-left:30px;
}
#btn{
margin-left:90px;
}
td{
height:45px;
text-align:right;
}
</style>
  </head>
  
  <body>
  <div>
<form action="jsp/user/add_list">
<table>
<tr>
<td>二级管理员账号：</td>
<td><input type="text" id="name" name="username"></td>
<td id="show"></td>

</tr>
<tr>
<td>二级管理员密码：</td>
<td><input type="password" id="psd1"></td>
<td></td>
</tr>
<tr>
<td>重复输入密码：</td>
<td><input type="password" id="psd2" name="password"></td>
<td id="show2"></td>
</tr>
<tr>
<td>电子邮件：</td>
<td><input type="text" name="email"></td>
<td></td>
</tr>
<tr>
<td>账号状态：</td>
<td><select name="state">
<option>正常</option>
<option>停用</option>
</select></td>
<td></td>
</tr>
</table>
<input type="submit" value="提交" class="bt" id="btn" /><input type="button" id="btn1" value="重置" class="bt" onclick="res()"/>
</form>
</div>
  </body>
  <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
  <script type="text/javascript">

  $(document).ready(function(){
   $("#btn").attr("disabled", true);
  $("#name").blur(function(){
  var obj={};
  	obj.username=$(this).val();
  	if($(this).val()==""||$.trim($(this).val()).length==0){
  	
  	$('#show').text("请输入账号").css("color","red");
  		  $("#btn").attr("disabled", true);
  		
  	}else{
  		$.post('<%= basePath%>jsp/user/yz_list',obj,cl,'json');
  	}
  
  });
  
    $("#psd2").blur(function(){
    if($('#psd1').val()==""||$('#psd2').val()==""||$.trim($(this).val()).length==0||$.trim($('#psd1').val()).length==0){
   
     $('#show2').text("请输入密码").css("color","red");
       $("#btn").attr("disabled", true);
    }
   	else if($('#psd1').val()==$('#psd2').val()){
    $('#show2').text("两次密码相同").css("color","green");
    if($('#show').text()=="账号可用"){
   
    $("#btn").attr("disabled", false);
    }
      
    }	
    else{
    $('#show2').text("两次密码不相同").css("color","red");
    $("#btn").attr("disabled", true);
    }
    });
    
  
  });
  
  
  function cl(data){
  	if(data.state=="1"){
  	$('#show').text("账号可用").css("color","green");
  	
  		  if($('#show2').text()=="两次密码相同"){
   
    	$("#btn").attr("disabled", false);
    }
  	}else{
  	$('#show').text("账号已存在").css("color","red");
  		  $("#btn").attr("disabled", true);
  		}
  		
  		
  	}
  	
  	function res(){
  	  		
    	
  	$("#btn").attr("disabled", true);
$('table input').val("");
	$('#show').text("");
	$('#show2').text("");
  	}

  </script>
</html>
